package com.jx.controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.jx.model.Func;
import com.jx.service.AddFuncService;
import com.jx.servicrimpl.AddFuncServiceImpl;

public class AddFuncController extends HttpServlet{
	AddFuncService afs=new AddFuncServiceImpl();
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doPost(req, resp);
	}
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stub
		req.setCharacterEncoding("UTF8");
		//从前台获取数据
		String fname=req.getParameter("fname");
		String fdes=req.getParameter("fdes");
		int fparentid=Integer.parseInt(req.getParameter("fparentid"));
		String fstate=req.getParameter("fstate");
		String fpath=req.getParameter("fpath");
		//实例化功能
		Func func=new Func(fname,fdes,fparentid,fstate,fpath);
		//调用增加功能的方法
		boolean result=afs.addFuncService(func);
		//传回数据
		PrintWriter pw=resp.getWriter();
		pw.write(String.valueOf(result));
	}
}
